package com.raceway.ihcenterapp.web;

import com.raceway.ihcenterapp.domain.IHS;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.springframework.roo.addon.web.mvc.controller.RooWebScaffold;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@RooWebScaffold(path = "asis", formBackingObject = IHS.class)
@RequestMapping("/asis")
@Controller
public class ASIController {


	@RequestMapping(method = RequestMethod.POST)
    public String create(@Valid IHS ASI, BindingResult result, Model model, HttpServletRequest request) {
        if (result.hasErrors()) {
            model.addAttribute("ASI", ASI);
            return "asis/create";
        }
        ASI.persist();
        return "redirect:/asis/" + encodeUrlPathSegment(ASI.getId().toString(), request);
    }
}
